<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="js/vue.min.js"></script>
    <title>v-for和v-bind结合使用</title>
    <style>
        .active{
            color:red;
        }
    </style>
</head>
<body>
<div id="app">
    <h2>{{message}}</h2>
    <ul>
        <li v-for="(item,index) in movies" :key="index" :class="{active:index===currentIndex}" @click="changeColor(index)">
            {{index+"---"+item}}
        </li>
    </ul>
</div>
</body>
<script>
    const app = new Vue({
        el: "#app",
        data: {
            message: "vue列表展示",
            movies: ['异形', '哆啦a梦', '大话西游'],
            currentIndex:0
        },
        methods: {
            changeColor(index){
                this.currentIndex = index
            }
        }
    });
</script>
</html>